﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Assist;
using Microsoft.CSharp.RuntimeBinder;
using Microsoft.Office.Interop.Excel;
using YJKExcelFormTool.DataDefine;
using YJKExcelFormTool.Utilities;

namespace YJKExcelFormTool.Analyser
{
	public class ExcelTableAnalyser
	{
		public bool CreateDoc()
		{
			bool result;
			try
			{
                //this.m_App = (Application)Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("00024500-0000-0000-C000-000000000046")));
                //this.m_App.Visible = true;
                //this.m_WorkBook = this.m_App.Workbooks.Add(1);
                //if (ExcelTableAnalyser.<>o__6.<>p__0 == null)
                //{
                //    ExcelTableAnalyser.<>o__6.<>p__0 = CallSite<Func<CallSite, object, Worksheet>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.ConvertExplicit, typeof(Worksheet), typeof(ExcelTableAnalyser)));
                //}
                //this.m_Worksheet = ExcelTableAnalyser.<>o__6.<>p__0.Target(ExcelTableAnalyser.<>o__6.<>p__0, this.m_WorkBook.Sheets[1]);
				result = true;
			}
			catch (Exception)
			{
				if (this.m_App != null)
				{
					this.m_App.Quit();
					this.m_App = null;
				}
				this.m_WorkBook = null;
				this.m_Worksheet = null;
				result = false;
			}
			return result;
		}

		public bool CreateDoc(string templatePath, int sheetIndex)
		{
			bool result;
			try
			{
                //this.m_App = (Application)Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("00024500-0000-0000-C000-000000000046")));
                //object value = Missing.Value;
                //this.m_App.Visible = true;
                //this.m_WorkBook = this.m_App.Workbooks.Open(templatePath, value, value, value, value, value, value, value, value, value, value, value, value, value, value);
                //if (ExcelTableAnalyser.<>o__7.<>p__0 == null)
                //{
                //    ExcelTableAnalyser.<>o__7.<>p__0 = CallSite<Func<CallSite, object, Worksheet>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.ConvertExplicit, typeof(Worksheet), typeof(ExcelTableAnalyser)));
                //}
                //this.m_Worksheet = ExcelTableAnalyser.<>o__7.<>p__0.Target(ExcelTableAnalyser.<>o__7.<>p__0, this.m_WorkBook.Sheets[sheetIndex + 1]);
				result = true;
			}
			catch (Exception)
			{
				if (this.m_App != null)
				{
					this.m_App.Quit();
					this.m_App = null;
				}
				this.m_WorkBook = null;
				this.m_Worksheet = null;
				result = false;
			}
			return result;
		}

		public bool Init(string filePath)
		{
			this.m_FilePath = filePath;
			this.m_App = (Application)Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("00024500-0000-0000-C000-000000000046")));
			bool result;
			try
			{
				this.m_App.Visible = false;
				object value = Missing.Value;
				this.m_WorkBook = this.m_App.Workbooks.Open(filePath, value, value, value, value, value, value, value, value, value, value, value, value, value, value);
				result = true;
			}
			catch (Exception)
			{
				if (this.m_App != null)
				{
					this.m_App.Quit();
					this.m_App = null;
				}
				this.m_WorkBook = null;
				this.m_Worksheet = null;
				result = false;
			}
			return result;
		}

		public void Save()
		{
			try
			{
				this.m_WorkBook.Save();
			}
			catch (Exception)
			{
				if (this.m_App != null)
				{
					this.m_App.Quit();
					this.m_App = null;
				}
				this.m_WorkBook = null;
				this.m_Worksheet = null;
			}
		}

		public void Close()
		{
			try
			{
				this.m_App.DisplayAlerts = false;
				this.m_App.AlertBeforeOverwriting = false;
			}
			finally
			{
				if (this.m_App != null)
				{
					this.m_App.Quit();
					this.m_App = null;
				}
				this.m_WorkBook = null;
				this.m_Worksheet = null;
			}
		}

		public void NewWorkSheet(int workSheetIndex)
		{
            //if (ExcelTableAnalyser.<>o__11.<>p__0 == null)
            //{
            //    ExcelTableAnalyser.<>o__11.<>p__0 = CallSite<Action<CallSite, Worksheet, object, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.InvokeMember(CSharpBinderFlags.ResultDiscarded, "Copy", null, typeof(ExcelTableAnalyser), new CSharpArgumentInfo[]
            //    {
            //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null),
            //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null),
            //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
            //    }));
            //}
            //ExcelTableAnalyser.<>o__11.<>p__0.Target(ExcelTableAnalyser.<>o__11.<>p__0, this.m_Worksheet, Type.Missing, this.m_App.Worksheets[workSheetIndex + 1]);
		}

		public void SetWorkSheet(int index)
		{
            //if (ExcelTableAnalyser.<>o__12.<>p__0 == null)
            //{
            //    ExcelTableAnalyser.<>o__12.<>p__0 = CallSite<Func<CallSite, object, Worksheet>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.ConvertExplicit, typeof(Worksheet), typeof(ExcelTableAnalyser)));
            //}
            //this.m_Worksheet = ExcelTableAnalyser.<>o__12.<>p__0.Target(ExcelTableAnalyser.<>o__12.<>p__0, this.m_App.Worksheets.get_Item(index + 1));
		}

		public void SetWorkSheetName(string name)
		{
			this.m_Worksheet.Name = name;
		}

		public void GetSheetsWithDoc(string filePath, ref List<string> sheetsNameList)
		{
			try
			{
				foreach (object obj in this.m_WorkBook.Sheets)
				{
					string name = ((Worksheet)obj).Name;
					sheetsNameList.Add(name);
				}
			}
			catch (Exception)
			{
				if (this.m_App != null)
				{
					this.m_App.Quit();
					this.m_App = null;
				}
				this.m_WorkBook = null;
				this.m_Worksheet = null;
			}
		}

		public void ReadDoc(string filePath, int sheetIndex, ref TableHead headInfos)
		{
			this.m_FilePath = filePath;
			try
			{
				if (sheetIndex >= this.m_WorkBook.Sheets.Count)
				{
					if (this.m_App != null)
					{
						this.m_App.Quit();
						this.m_App = null;
					}
					this.m_WorkBook = null;
				}
				else
				{
                    //if (ExcelTableAnalyser.<>o__15.<>p__0 == null)
                    //{
                    //    ExcelTableAnalyser.<>o__15.<>p__0 = CallSite<Func<CallSite, object, Worksheet>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.ConvertExplicit, typeof(Worksheet), typeof(ExcelTableAnalyser)));
                    //}
                    //this.m_Worksheet = ExcelTableAnalyser.<>o__15.<>p__0.Target(ExcelTableAnalyser.<>o__15.<>p__0, this.m_WorkBook.Sheets[sheetIndex + 1]);
					this.GetHeadInfos(sheetIndex, ref headInfos);
					this.GetCells(ref headInfos);
				}
			}
			catch (Exception)
			{
				if (this.m_App != null)
				{
					this.m_App.Quit();
					this.m_App = null;
				}
				this.m_WorkBook = null;
				this.m_Worksheet = null;
			}
		}

		private bool IsNullRange(Range range)
		{
            //if (ExcelTableAnalyser.sso__16.ssp__0 == null)
            //{
            //    ExcelTableAnalyser.<>o__16.<>p__0 = CallSite<Func<CallSite, object, bool>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.UnaryOperation(CSharpBinderFlags.None, ExpressionType.IsTrue, typeof(ExcelTableAnalyser), new CSharpArgumentInfo[]
            //    {
            //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
            //    }));
            //}
            //if (ExcelTableAnalyser.<>o__16.<>p__0.Target(ExcelTableAnalyser.<>o__16.<>p__0, range.MergeCells))
            //{
            //    Range mergeArea = range.MergeArea;
            //    int count = mergeArea.Cells.Rows.Count;
            //    int count2 = mergeArea.Cells.Columns.Count;
            //    for (int i = 1; i <= count; i++)
            //    {
            //        for (int j = 1; j <= count2; j++)
            //        {
            //            if (ExcelTableAnalyser.<>o__16.<>p__1 == null)
            //            {
            //                ExcelTableAnalyser.<>o__16.<>p__1 = CallSite<Func<CallSite, object, Range>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof(Range), typeof(ExcelTableAnalyser)));
            //            }
            //            Range range2 = ExcelTableAnalyser.<>o__16.<>p__1.Target(ExcelTableAnalyser.<>o__16.<>p__1, mergeArea.Cells[i, j]);
            //            if (ExcelTableAnalyser.<>o__16.<>p__2 == null)
            //            {
            //                ExcelTableAnalyser.<>o__16.<>p__2 = CallSite<Func<CallSite, object, string>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof(string), typeof(ExcelTableAnalyser)));
            //            }
            //            if (ExcelTableAnalyser.<>o__16.<>p__2.Target(ExcelTableAnalyser.<>o__16.<>p__2, range2.Text).CompareTo("") != 0)
            //            {
            //                return false;
            //            }
            //        }
            //    }
            //}
            //else
            //{
            //    if (ExcelTableAnalyser.<>o__16.<>p__3 == null)
            //    {
            //        ExcelTableAnalyser.<>o__16.<>p__3 = CallSite<Func<CallSite, object, string>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof(string), typeof(ExcelTableAnalyser)));
            //    }
            //    if (ExcelTableAnalyser.<>o__16.<>p__3.Target(ExcelTableAnalyser.<>o__16.<>p__3, range.Text).CompareTo("") != 0)
            //    {
            //        return false;
            //    }
            //}
			return true;
		}

		private void GetHeadInfos(int sheetIndex, ref TableHead headInfos)
		{
			int num = this.m_Worksheet.UsedRange.Rows.Count;
			int count = this.m_Worksheet.UsedRange.Columns.Count;
			for (int i = 1; i <= num; i++)
			{
				bool flag = true;
				for (int j = 1; j <= count; j++)
				{
                    //if (ExcelTableAnalyser.<>o__17.<>p__0 == null)
                    //{
                    //    ExcelTableAnalyser.<>o__17.<>p__0 = CallSite<Func<CallSite, object, Range>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof(Range), typeof(ExcelTableAnalyser)));
                    //}
                    //Range range = ExcelTableAnalyser.<>o__17.<>p__0.Target(ExcelTableAnalyser.<>o__17.<>p__0, this.m_Worksheet.Cells[i, j]);
                    //if (!this.IsNullRange(range))
                    //{
                    //    flag = false;
                    //}
				}
				if (flag)
				{
					num = i - 1;
					break;
				}
			}
			List<double> list = new List<double>();
			for (int k = 1; k <= num; k++)
			{
                //if (ExcelTableAnalyser.<>o__17.<>p__1 == null)
                //{
                //    ExcelTableAnalyser.<>o__17.<>p__1 = CallSite<Func<CallSite, object, Range>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof(Range), typeof(ExcelTableAnalyser)));
                //}
                //Range range2 = ExcelTableAnalyser.<>o__17.<>p__1.Target(ExcelTableAnalyser.<>o__17.<>p__1, this.m_Worksheet.Cells[k, 1]);
                //if (ExcelTableAnalyser.<>o__17.<>p__4 == null)
                //{
                //    ExcelTableAnalyser.<>o__17.<>p__4 = CallSite<Action<CallSite, List<double>, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.InvokeMember(CSharpBinderFlags.ResultDiscarded, "Add", null, typeof(ExcelTableAnalyser), new CSharpArgumentInfo[]
                //    {
                //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null),
                //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
                //    }));
                //}
                //Action<CallSite, List<double>, object> target = ExcelTableAnalyser.<>o__17.<>p__4.Target;
                //CallSite <>p__ = ExcelTableAnalyser.<>o__17.<>p__4;
                //List<double> arg = list;
                //if (ExcelTableAnalyser.<>o__17.<>p__3 == null)
                //{
                //    ExcelTableAnalyser.<>o__17.<>p__3 = CallSite<Func<CallSite, Type, object, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.InvokeMember(CSharpBinderFlags.None, "mmToFeet", null, typeof(ExcelTableAnalyser), new CSharpArgumentInfo[]
                //    {
                //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.IsStaticType, null),
                //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
                //    }));
                //}
                //Func<CallSite, Type, object, object> target2 = ExcelTableAnalyser.<>o__17.<>p__3.Target;
                //CallSite <>p__2 = ExcelTableAnalyser.<>o__17.<>p__3;
                //Type typeFromHandle = typeof(AssistFunc);
                //if (ExcelTableAnalyser.<>o__17.<>p__2 == null)
                //{
                //    ExcelTableAnalyser.<>o__17.<>p__2 = CallSite<Func<CallSite, object, double, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.BinaryOperation(CSharpBinderFlags.None, ExpressionType.Multiply, typeof(ExcelTableAnalyser), new CSharpArgumentInfo[]
                //    {
                //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
                //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.Constant, null)
                //    }));
                //}
                //target(<>p__, arg, target2(<>p__2, typeFromHandle, ExcelTableAnalyser.<>o__17.<>p__2.Target(ExcelTableAnalyser.<>o__17.<>p__2, range2.RowHeight, 0.3612)));
			}
			List<double> list2 = new List<double>();
			for (int l = 1; l <= count; l++)
			{
                //if (ExcelTableAnalyser.<>o__17.<>p__5 == null)
                //{
                //    ExcelTableAnalyser.<>o__17.<>p__5 = CallSite<Func<CallSite, object, Range>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof(Range), typeof(ExcelTableAnalyser)));
                //}
                //Range range3 = ExcelTableAnalyser.<>o__17.<>p__5.Target(ExcelTableAnalyser.<>o__17.<>p__5, this.m_Worksheet.Cells[1, l]);
                //if (ExcelTableAnalyser.<>o__17.<>p__8 == null)
                //{
                //    ExcelTableAnalyser.<>o__17.<>p__8 = CallSite<Action<CallSite, List<double>, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.InvokeMember(CSharpBinderFlags.ResultDiscarded, "Add", null, typeof(ExcelTableAnalyser), new CSharpArgumentInfo[]
                //    {
                //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null),
                //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
                //    }));
                //}
                //Action<CallSite, List<double>, object> target3 = ExcelTableAnalyser.<>o__17.<>p__8.Target;
                //CallSite <>p__3 = ExcelTableAnalyser.<>o__17.<>p__8;
                //List<double> arg2 = list2;
                //if (ExcelTableAnalyser.<>o__17.<>p__7 == null)
                //{
                //    ExcelTableAnalyser.<>o__17.<>p__7 = CallSite<Func<CallSite, Type, object, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.InvokeMember(CSharpBinderFlags.None, "mmToFeet", null, typeof(ExcelTableAnalyser), new CSharpArgumentInfo[]
                //    {
                //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.IsStaticType, null),
                //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
                //    }));
                //}
                //Func<CallSite, Type, object, object> target4 = ExcelTableAnalyser.<>o__17.<>p__7.Target;
                //CallSite <>p__4 = ExcelTableAnalyser.<>o__17.<>p__7;
                //Type typeFromHandle2 = typeof(AssistFunc);
                //if (ExcelTableAnalyser.<>o__17.<>p__6 == null)
                //{
                //    ExcelTableAnalyser.<>o__17.<>p__6 = CallSite<Func<CallSite, object, double, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.BinaryOperation(CSharpBinderFlags.None, ExpressionType.Multiply, typeof(ExcelTableAnalyser), new CSharpArgumentInfo[]
                //    {
                //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
                //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.Constant, null)
                //    }));
                //}
                //target3(<>p__3, arg2, target4(<>p__4, typeFromHandle2, ExcelTableAnalyser.<>o__17.<>p__6.Target(ExcelTableAnalyser.<>o__17.<>p__6, range3.ColumnWidth, 2.2862)));
			}
			int badyStartRowNumber = num + 1;
			int badyEndRowNumber = this.CalculateEndRowNum(this.m_Worksheet);
			TableSourceInfo tableSourceInfo = new TableSourceInfo(this.m_FilePath, sheetIndex, badyStartRowNumber, badyEndRowNumber);
			headInfos = new TableHead(TableHead._Tag_HeadType.HT_EXCEL, tableSourceInfo, null, num, count, list, list2);
		}

		private int CalculateEndRowNum(Worksheet workSheet)
		{
			int result = 36;
			string printArea = workSheet.PageSetup.PrintArea;
			if (printArea == null)
			{
				return result;
			}
			int num = printArea.LastIndexOf("$");
			if (num > -1)
			{
				result = Convert.ToInt32(printArea.Substring(num + 1, printArea.Length - num - 1));
			}
			return result;
		}

		private void GetCells(ref TableHead headInfos)
		{
			List<TableHeadCell> list = new List<TableHeadCell>();
			int rowSize = headInfos.RowSize;
			int columnSize = headInfos.ColumnSize;
			for (int i = 1; i <= rowSize; i++)
			{
				for (int j = 1; j <= columnSize; j++)
				{
					TableHeadCell item = null;
					if (this.GetCell(i, j, ref item))
					{
						list.Add(item);
					}
				}
			}
			headInfos.TableHeadInfos = list;
		}

		private bool GetCell(int row, int col, ref TableHeadCell cell)
		{
            //if (ExcelTableAnalyser.<>o__20.<>p__0 == null)
            //{
            //    ExcelTableAnalyser.<>o__20.<>p__0 = CallSite<Func<CallSite, object, Range>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof(Range), typeof(ExcelTableAnalyser)));
            //}
            //Range range = ExcelTableAnalyser.<>o__20.<>p__0.Target(ExcelTableAnalyser.<>o__20.<>p__0, this.m_Worksheet.Cells[row, col]);
            //if (ExcelTableAnalyser.<>o__20.<>p__2 == null)
            //{
            //    ExcelTableAnalyser.<>o__20.<>p__2 = CallSite<Func<CallSite, object, bool>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.UnaryOperation(CSharpBinderFlags.None, ExpressionType.IsTrue, typeof(ExcelTableAnalyser), new CSharpArgumentInfo[]
            //    {
            //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
            //    }));
            //}
            //Func<CallSite, object, bool> target = ExcelTableAnalyser.<>o__20.<>p__2.Target;
            //CallSite <>p__ = ExcelTableAnalyser.<>o__20.<>p__2;
            //if (ExcelTableAnalyser.<>o__20.<>p__1 == null)
            //{
            //    ExcelTableAnalyser.<>o__20.<>p__1 = CallSite<Func<CallSite, object, bool, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.BinaryOperation(CSharpBinderFlags.None, ExpressionType.Equal, typeof(ExcelTableAnalyser), new CSharpArgumentInfo[]
            //    {
            //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.Constant, null)
            //    }));
            //}
            //if (target(<>p__, ExcelTableAnalyser.<>o__20.<>p__1.Target(ExcelTableAnalyser.<>o__20.<>p__1, range.MergeCells, true)))
            //{
            //    Range mergeArea = range.MergeArea;
            //    if (mergeArea.Row != row || mergeArea.Column != col)
            //    {
            //        return false;
            //    }
            //    int count = mergeArea.Cells.Rows.Count;
            //    List<int> list = new List<int>();
            //    for (int i = 0; i < count; i++)
            //    {
            //        list.Add(row - 1 + i);
            //    }
            //    int count2 = mergeArea.Cells.Columns.Count;
            //    List<int> list2 = new List<int>();
            //    for (int j = 0; j < count2; j++)
            //    {
            //        list2.Add(col - 1 + j);
            //    }
            //    if (ExcelTableAnalyser.<>o__20.<>p__3 == null)
            //    {
            //        ExcelTableAnalyser.<>o__20.<>p__3 = CallSite<Func<CallSite, Type, List<int>, List<int>, object, TableHeadCellKey, TableHeadCell>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.InvokeConstructor(CSharpBinderFlags.None, typeof(ExcelTableAnalyser), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.IsStaticType, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
            //        }));
            //    }
            //    cell = ExcelTableAnalyser.<>o__20.<>p__3.Target(ExcelTableAnalyser.<>o__20.<>p__3, typeof(TableHeadCell), list, list2, range.Text, new TableHeadCellKey(""));
            //}
            //else
            //{
            //    List<int> list3 = new List<int>();
            //    list3.Add(row - 1);
            //    List<int> list4 = new List<int>();
            //    list4.Add(col - 1);
            //    if (ExcelTableAnalyser.<>o__20.<>p__4 == null)
            //    {
            //        ExcelTableAnalyser.<>o__20.<>p__4 = CallSite<Func<CallSite, Type, List<int>, List<int>, object, TableHeadCellKey, TableHeadCell>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.InvokeConstructor(CSharpBinderFlags.None, typeof(ExcelTableAnalyser), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.IsStaticType, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
            //        }));
            //    }
            //    cell = ExcelTableAnalyser.<>o__20.<>p__4.Target(ExcelTableAnalyser.<>o__20.<>p__4, typeof(TableHeadCell), list3, list4, range.Text, new TableHeadCellKey(""));
            //}
            //Comment comment = range.Comment;
            //if (comment != null)
            //{
            //    cell.Key = new TableHeadCellKey(comment.Text(Type.Missing, Type.Missing, Type.Missing));
            //}
			return true;
		}

		public void InsertData(ExcelRange be)
		{
			if (this.m_Worksheet == null)
			{
				return;
			}
			this.m_Worksheet.Cells[be.Row, be.Col] = be.Text;
			this.m_WorkSheet_range = this.m_Worksheet.get_Range(be.StartCell, be.EndCell);
			this.m_WorkSheet_range.MergeCells = be.IsMerge;
			this.m_WorkSheet_range.Borders.Color = System.Drawing.Color.Black.ToArgb();
			this.m_WorkSheet_range.NumberFormat = be.Formart;
			if (be.Key != string.Empty)
			{
				try
				{
					this.m_Worksheet.get_Range(be.StartCell, Type.Missing).AddComment(be.Key).Visible = false;
				}
				catch (Exception)
				{
				}
			}
		}

		public void InsertData(ExcelRange be, string fontName, int fontSize, XlHAlign alignmentH, XlVAlign alignmentV)
		{
			if (this.m_Worksheet == null)
			{
				return;
			}
			this.m_Worksheet.Cells[be.Row, be.Col] = be.Text;
			this.m_WorkSheet_range = this.m_Worksheet.get_Range(be.StartCell, be.EndCell);
			this.m_WorkSheet_range.MergeCells = be.IsMerge;
			this.m_WorkSheet_range.Borders.Color = System.Drawing.Color.Black.ToArgb();
			this.m_WorkSheet_range.Font.Name = fontName;
			this.m_WorkSheet_range.Font.Size = fontSize;
			this.m_WorkSheet_range.Font.Color = this.GetColorValue(be.FontColor);
			this.m_WorkSheet_range.VerticalAlignment = alignmentH;
			this.m_WorkSheet_range.HorizontalAlignment = alignmentV;
			this.m_WorkSheet_range.NumberFormat = be.Formart;
			if (be.Key != string.Empty)
			{
				try
				{
					this.m_Worksheet.get_Range(be.StartCell, Type.Missing).AddComment(be.Key).Visible = false;
				}
				catch (Exception)
				{
				}
			}
		}

		public void SetWidthHeight(List<double> colWidth, List<double> rowHeight)
		{
			if (this.m_Worksheet == null)
			{
				return;
			}
			for (int i = 0; i < colWidth.Count; i++)
			{
				string cell = Common.AscII2Chr(i + 65) + "1";
				this.m_WorkSheet_range = this.m_Worksheet.get_Range(cell, Type.Missing);
				this.m_WorkSheet_range.ColumnWidth = colWidth[i];
			}
			for (int i = 0; i < rowHeight.Count; i++)
			{
				string cell2 = "A" + (i + 1).ToString();
				this.m_WorkSheet_range = this.m_Worksheet.get_Range(cell2, Type.Missing);
				this.m_WorkSheet_range.RowHeight = rowHeight[i];
			}
		}

		private int GetColorValue(string interiorColor)
		{
			uint num = YArchitech.Revit.PrivateImplementationDetails.ComputeStringHash(interiorColor);
			if (num <= 1750494276u)
			{
				if (num <= 503408093u)
				{
					if (num != 220516796u)
					{
						if (num == 503408093u)
						{
							if (interiorColor == "PeachPuff")
							{
								return System.Drawing.Color.PeachPuff.ToArgb();
							}
						}
					}
					else if (interiorColor == "LightGray")
					{
						return System.Drawing.Color.LightGray.ToArgb();
					}
				}
				else if (num != 1042463963u)
				{
					if (num == 1750494276u)
					{
						if (interiorColor == "BLACK")
						{
							return System.Drawing.Color.Black.ToArgb();
						}
					}
				}
				else if (interiorColor == "GAINSBORO")
				{
					return System.Drawing.Color.Gainsboro.ToArgb();
				}
			}
			else if (num <= 2964049737u)
			{
				if (num != 2856149510u)
				{
					if (num == 2964049737u)
					{
						if (interiorColor == "YELLOW")
						{
							return System.Drawing.Color.Yellow.ToArgb();
						}
					}
				}
				else if (interiorColor == "WHITE")
				{
					return System.Drawing.Color.White.ToArgb();
				}
			}
			else if (num != 4012036346u)
			{
				if (num == 4159498394u)
				{
					if (interiorColor == "GRAY")
					{
						return System.Drawing.Color.Gray.ToArgb();
					}
				}
			}
			else if (interiorColor == "Turquoise")
			{
				return System.Drawing.Color.Turquoise.ToArgb();
			}
			return System.Drawing.Color.White.ToArgb();
		}

		private string m_FilePath = "";

		private Application m_App;

		private Workbook m_WorkBook;

		private Worksheet m_Worksheet;

		private Range m_WorkSheet_range;
	}
}
